package Text24;
import java.util.*;
public class Main {
    public static int N = 510,max=Integer.MAX_VALUE;
    public static int[][] a = new int[N][N];
    public static int[][] f = new int[N][N];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <=i ; j++) {
                a[i][j]=scanner.nextInt();
            }
        }
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i + 1; j++) {
                f[i][j]=-max;
            }
        }
        f[1][1]=a[1][1];
        for (int i = 2; i <=n ; i++) {
            for (int j = 1; j <=i ; j++) {
                f[i][j]=Math.max(f[i-1][j-1]+a[i][j],f[i-1][j]+a[i][j]);
            }
        }
        int res=-max;
        for (int i = 1; i <= n; i++) {
            res=Math.max(res,f[n][i]);
        }
        System.out.println(res);
    }
}
